package com.team11.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team11.server.mapper.KcInformationMapper;
import com.team11.server.pojo.KcInformation;
import com.team11.server.service.IKcInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pjc
 * @since 2021-06-14
 */
@Service
public class KcInformationServiceImpl extends ServiceImpl<KcInformationMapper, KcInformation> implements IKcInformationService {

    @Resource
    private KcInformationMapper kcInformationMapper;

    /**
     * 获取所有课程表
     * @return s
     */
    @Override
    public Object getAllKcName() {
//        List<Map<String, Object>> list = kcInformationMapper.selectMaps(new QueryWrapper<KcInformation>().select("kc_id","kc_name"));// 获取了表中所有数据

        List<KcInformation> items = kcInformationMapper.selectList(null);
        return items.stream().map(KcInformation::getKcName).collect(Collectors.toList());
    }


    @Override
    public Object getAllKcNameAndId() {
        return kcInformationMapper.selectMaps(new QueryWrapper<KcInformation>().select("kc_id","kc_name"));
    }


}
